<template>
  <div>
    <el-card>
      <el-form ref="form" :model="formData" label-width="80px">
        <el-row>
          <el-col :span="18">
            <el-form-item label="监督机构" prop="orgId" style="margin-left: 50px;margin-top: 20px">
              <el-select v-model="formData.orgId" clearable style="margin-left: 20px;" placeholder="请选择">
                <el-option
                  v-for="item in orglist"
                  :key="item.id"
                  :label="item.orgName"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" style="margin-top: 20px">
            <el-button type="success" @click="quire">检索</el-button>
            <el-button>导出</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-card>

    <el-card>
      <el-table
        :data="personlist"
        border style="width:100%; font-size: 5px;">
        <el-table-column
          prop="jobLevel"
          label="项目"
          width="160">
        </el-table-column>
        <el-table-column>
          <el-table-column label="合计" prop="num" width="60"></el-table-column>
          <el-table-column label="少数民族" prop="folk" width="50"></el-table-column>
          <el-table-column label="中国党员" prop="pol" width="50"></el-table-column>
        </el-table-column>
        <el-table-column  label="年龄" width="70">
          <el-table-column label="25岁以下" width="70" prop="a">
          </el-table-column>
          <el-table-column label="26到30岁" width="70" prop="b">
          </el-table-column>
          <el-table-column label="31岁到35岁" width="70" prop="c">
          </el-table-column>
          <el-table-column label="36岁到40岁" width="70" prop="d">
          </el-table-column>
          <el-table-column label="41岁到45岁" width="70" prop="e">
          </el-table-column>
          <el-table-column label="46岁到50岁" width="70" prop="f">
          </el-table-column>
          <el-table-column label="51岁到54岁" width="70" prop="g">
          </el-table-column>
          <el-table-column label="55岁及以上" width="70" prop="h">
          </el-table-column>
        </el-table-column>
        <el-table-column label="性别">
          <el-table-column label="男" prop="men"  width="50">
          </el-table-column>
          <el-table-column label="女" prop="women" width="50">
          </el-table-column>
        </el-table-column>
        <el-table-column  label="学历" width="20">
          <el-table-column label="博士" prop="doctor" width="70">
          </el-table-column>
          <el-table-column label="研究生" prop="Master" width="70">
          </el-table-column>
          <el-table-column label="大学本科" prop="undergraduate" width="70">
          </el-table-column>
          <el-table-column label="大学专科" prop="college" width="70">
          </el-table-column>
          <el-table-column label="中专" prop="special" width="70">
          </el-table-column>
          <el-table-column label="高中及以下" prop="st" width="50">
          </el-table-column>
        </el-table-column>

      </el-table>
    </el-card>
  </div>
</template>

<script>
  import {post} from "@/utils/api";
  export default {
    data() {
      return {
        formData:{},
        orglist:[],
        personlist:[],
        list:[],
        ids:[]
      }
    },
    async created() {
      let res = await post("org/getallorg")
      this.orglist = res
      let res1 = await post("person/getallorgid")
      this.ids = res1.map((item,index)=>{
        return item.orgId
      })
        console.log(this.ids)
      this.getbypage()
    },
    methods: {
      async getbypage() {
        let res1 = await post("leader/get1", {id: this.ids})
        let res2 = await post("leader/get2", {id: this.ids})
        let res3 = await post("leader/get3", {id: this.ids})
        let res4 = await post("leader/get4", {id: this.ids})
        let res5 = await post("leader/get5", {id: this.ids})
        let res6 = await post("leader/get6", {id: this.ids})
        this.list = res1.map((item,index)=>{
          return {...item,...res2[index],...res3[index],...res4[index],...res5[index],...res6[index]}
        })
        this.personlist = this.list.map(item=>{
          if(item.jobLevel == 9)
            item.jobLevel = '科办员';
          if(item.jobLevel==8)
            item.jobLevel = '乡科级副职';
          if(item.jobLevel ==7)
            item.jobLevel = '乡科级正职';
          if(item.jobLevel==6)
            item.jobLevel = '县处级副职';
          if(item.jobLevel ==5)
            item.jobLevel = '县处级正职';
          if(item.jobLevel==4)
            item.jobLevel = '厅局级副职';
          if(item.jobLevel == 3)
            item.jobLevel = '厅局级正职';
          if(item.jobLevel==2)
            item.jobLevel = '省部级副职';
          if(item.jobLevel == 1)
            item.jobLevel = '省部级正职';
          if(item.jobLevel==0)
            item.jobLevel = '无职级';
          return item
        })
        console.log(this.personlist);
      },
      async quire() {
        console.log(this.formData.orgId)
        // this.ids=[]
          this.ids = this.formData.orgId
          let res1 = await post("leader/get1", {id: this.ids})
          let res2 = await post("leader/get2", {id: this.ids})
          let res3 = await post("leader/get3", {id: this.ids})
          let res4 = await post("leader/get4", {id: this.ids})
          let res5 = await post("leader/get5", {id: this.ids})
          let res6 = await post("leader/get6", {id: this.ids})
          this.list = res1.map((item,index)=>{
            return {...item,...res2[index],...res3[index],...res4[index],...res5[index],...res6[index]}
          })
          this.personlist = this.list.map(item=>{
            if(item.jobLevel == 9)
              item.jobLevel = '科办员';
            if(item.jobLevel==8)
              item.jobLevel = '乡科级副职';
            if(item.jobLevel ==7)
              item.jobLevel = '乡科级正职';
            if(item.jobLevel==6)
              item.jobLevel = '县处级副职';
            if(item.jobLevel ==5)
              item.jobLevel = '县处级正职';
            if(item.jobLevel==4)
              item.jobLevel = '厅局级副职';
            if(item.jobLevel == 3)
              item.jobLevel = '厅局级正职';
            if(item.jobLevel==2)
              item.jobLevel = '省部级副职';
            if(item.jobLevel == 1)
              item.jobLevel = '省部级正职';
            if(item.jobLevel==0)
              item.jobLevel = '无职级';
            return item
          })
        console.log(this.personlist)
      },

    }
  }
</script>
<style></style>
